package fun.stgoder.bmwf.test1.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import fun.stgoder.bmwf.core.exception.BaseException;
import fun.stgoder.bmwf.test1.domain.Test1;
import fun.stgoder.bmwf.test1.mapper.Test1Mapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class Test1Service {
    @Resource
    Test1Mapper test1Mapper;

    public List<Test1> f1(String p) {
        Test1 test1 = new Test1();
        String str = String.valueOf(System.currentTimeMillis());
        test1.setId(str);
        test1.setName("name-" + str);
        test1Mapper.insert(test1);
        if ("1".equalsIgnoreCase(p))
            throw new BaseException(-1, "test1 Transactional");
        return test1Mapper.selectList(new QueryWrapper<>());
    }
}
